/*
 * Copyright 2016-2018 www.jeesuite.com.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.jeesuite.mybatis.spring;

import org.apache.ibatis.session.Configuration;
import org.springframework.core.io.Resource;

import com.jeesuite.mybatis.Configs;
import com.jeesuite.mybatis.parser.MybatisMapperParser;

/**
 * @description <br>
 * @author <a href="mailto:vakinge@gmail.com">vakin</a>
 * @date 2018年11月22日
 */
public class SqlSessionFactoryBean extends org.mybatis.spring.SqlSessionFactoryBean{

	public void setCrudDriver(String crudDriver) {
		Configs.addProperty(Configs.CRUD_DRIVER, crudDriver);
	}

	public void setDbType(String dbType) {
		Configs.addProperty(Configs.DB_TYPE, dbType);
	}

	@Override
	public void setMapperLocations(Resource[] mapperLocations) {
		super.setMapperLocations(mapperLocations);
		MybatisMapperParser.addMapperLocations(mapperLocations);
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		super.afterPropertiesSet();
		Configuration configuration = getObject().getConfiguration();
		AutoCrudRegtisty.register(configuration);
	}
	
	
	
}
